HAL FLASH migration: List of applicable concepts ¶
This section provides information about the HAL FLASH applicable architecture concepts.
In HAL1, the FLASH driver manages Flash memory operations.
In HAL2, depending on the device family, memory operations are managed either by the FLASH driver or by the NVM driver.
For NVM-based families, the NVM driver provides programming services similar to those of FLASH with minor differences:
There is no erase step for NVM memories.
Erase-by-address, page erase, bank erase, and mass erase remain FLASH-specific.
For NVM-based families, the only erase service that may be exposed is OBK erase, when that feature exists.
In this migration guide, when a concept exists in both HAL2 FLASH and HAL2 NVM, the migration is illustrated using the HAL2 FLASH name. The same naming rule applies to HAL2 NVM.
Concepts for FLASH ¶
|
Concept |
Description |
|---|---|
|
Rework the HAL FLASH driver APIs to improve modularity and flexibility.
Note All control and feature APIs such as lock/unlock, prefetch, ECC enable/disable, and option bytes management are handled separately in the hal_flash_itf.h/c. Option bytes are also managed on the ITF side using dedicated APIs, as these are one-shot operations not based on the handle. |
|
|
There is no init or configuration functions needed in HAL1. In HAL2 the HAL FLASH driver has been fully reworked:
|
|
|
New HAL handle
|
|
|
New configuration APIs are available to set FLASH features. |
|
|
Set/Get User Data functions
|
|
|
Individual callback registration APIs replace global register and unregister functions |
The callback registration is handled by specific functions for each FLASH event. These functions are used to register callback functions for different FLASH events. |
|
Global
Note
All the above IRQ handlers are dedicated to FLASH IO operations. Additionally, there is a separate IRQ handler named
|
|
|
HAL FLASH APIs now rely on LL APIs rather than performing direct register access. |
|
|
Define statements and enumerations redirected to LL equivalents |
HAL FLASH define statements and enumerations are based on LL define statements. |
|
All hardware macros have been removed from the HAL FLASH driver, and equivalent services are ensured through the LL APIs. |
|
|
The FLASH IO is now managed by three states:
Note There is no state machine implemented for the FLASH ITF driver. |
|
|
The HAL FLASH functions were updated to return:
|
|
|
Redesigned error handling mechanisms within HAL to improve detection, reporting, and handling of errors, providing more detailed and consistent error codes. |
|
|
All TypeDef parts of the HAL FLASH driver have been removed and replaced by
|
|
|
Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable. |
|
|
Updated HAL inclusion mechanism to improve modularity and reduce compilation dependencies. |
|
|
Merge HAL extension files with common ones and remove the EX prefix from APIs. |
Only one HAL FLASH header file remains and all macros, define statements, and functions from
|
|
Improved HAL FLASH driver portability to better support multi-bank handling. Introduced a new FLASH handle structure
|
|
|
Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels. |
Finite parameters (including FLASH instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety. |
|
In HAL2, the implementation of
|
|
|
Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions). |
All HAL FLASH functions now start with
|
Other HAL FLASH changes ¶
|
Concept |
Consideration |
|---|---|
|
Granularity for secure/non-secure FLASH usage |
Provides full granularity for FLASH operations in both secure and non-secure contexts. This enables independent management of FLASH programming and access in the secure world and the non-secure world. For example:
|